package com.googlecode.bpmcenter.model;
 
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
 
@Entity
@Table(name="BPM_FILE")
public class File {
 
    private Long id;
    private String name;
    private Folder folder;
    private String description;
    private String format;
    
    private List<Order> orders;
    private List<OrderItem> orderItems;
 
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID")
    public Long getId() {
        return id;
    }
 
    public void setId(Long id) {
        this.id = id;
    }
 
    @Column(name = "NAME")
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    @Column(name = "DESCRIPTION")
		public String getDescription() {
    	return description;
    }

		public void setDescription(String description) {
    	this.description = description;
    }

    @Column(name = "FORMAT")
		public String getFormat() {
    	return format;
    }

		public void setFormat(String format) {
    	this.format = format;
    }

  	@ManyToOne(targetEntity = Folder.class, fetch = FetchType.EAGER)
  	@JoinColumn(name = "FOLDER_ID")
		public Folder getFolder() {
    	return folder;
    }

		public void setFolder(Folder folder) {
    	this.folder = folder;
    }
		
		@ManyToMany(fetch = FetchType.LAZY, mappedBy = "files")
		public List<Order> getOrders() {
    	return orders;
    }

		public void setOrders(List<Order> orders) {
    	this.orders = orders;
    }
		
		@ManyToMany(fetch = FetchType.LAZY, mappedBy = "files")
		public List<OrderItem> getOrderItems() {
    	return orderItems;
    }

		public void setOrderItems(List<OrderItem> orderItems) {
    	this.orderItems = orderItems;
    }
		
    @Override
    public String toString() {
        StringBuffer strBuff = new StringBuffer();
        strBuff.append("id : ").append(getId());
        strBuff.append(", name : ").append(getName());
        return strBuff.toString();
    }

}